using System;
using UnityEngine;

public class SceneDialogueHappener : MonoBehaviour
{
    [Header("对话的类型")] [SerializeField] private Character characterType;

    [Header("对话结束前禁用的脚本")] [SerializeField]
    private MonoBehaviour[] scripts;

    [Header("是否隐藏玩家")] [SerializeField] private bool hidePlayer;

    private void Awake()
    {
        if(hidePlayer) PlayerController.Instance.HidePlayer();
        DialogueManager.Instance.StartDialogue(characterType);
        SetScriptsState(false);
    }

    /*private void OnEnable()
    {
        
    }*/

    private void Update()
    {
        if (DialogueManager.Instance.GetIsFinished())
        {
            SetScriptsState(true);
            enabled = false;
        }
    }

    private void SetScriptsState(bool value)
    {
        foreach (var script in scripts)
        {
            script.enabled = value;
        }
    }
}
